﻿using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;

namespace Enter.Admin.Configs
{
    // services.AddControllersWithViews(options => options.ModelMetadataDetailsProviders.Add(new CustomMetadataProvider()))
    public class CustomMetadataProvider : IMetadataDetailsProvider, IDisplayMetadataProvider
    {
        public void CreateDisplayMetadata(DisplayMetadataProviderContext context)
        {

            if (context.Key.MetadataKind == ModelMetadataKind.Property
                || context.Key.MetadataKind == ModelMetadataKind.Parameter
                || context.Key.MetadataKind == ModelMetadataKind.Type)
            {

                context.DisplayMetadata.ConvertEmptyStringToNull = false;
            }
        }
    }
}
